#ifndef _BMA222E_h
#define _BMA222E_h

#include <stdio.h>
#include <Arduino.h>
#include "Wire.h"

#define PM_NORMAL			0x00
#define PM_DEEP_SUSPEND	0x01
#define PM_LOW_POWER1		0x02
#define PM_LOW_POWER2		0x03
#define PM_SUSPEND			0x04

#define BMA222E_ADDR_R		0x31
#define BMA222E_ADDR_W		0x30

class BMA222E {

public:
    BMA222E();
	void begin(void);
    void setPowerMode(uint8_t mode);
	void getRawXYZ(int8_t *x_raw, int8_t *y_raw, int8_t *z_raw);
	void getXYZ(int16_t *x, int16_t *y, int16_t *z);
	int16_t getX(void);
	int16_t getY(void);
	int16_t getZ(void);

private:
	uint8_t dev_addr;
	void write_data(uint8_t reg, uint8_t data);
	void read_data(uint8_t start_reg, uint8_t *buffer, uint8_t len);
};


#endif //_BMA222E_h
